﻿<Controls:MetroWindow x:Class="NOnkyo.WpfGui.Views.AutoDetectView"                    
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:Controls="clr-namespace:MahApps.Metro.Controls;assembly=MahApps.Metro"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:vm="clr-namespace:NOnkyo.WpfGui.ViewModels"
        xmlns:properties="clr-namespace:NOnkyo.WpfGui.AttachedProperty"
        properties:CloseDialog.DialogResult="{Binding IsDialogClose}"
        Title="Scanning for Receiver" Height="300" Width="300" ShowIconOnTitleBar="False" WindowStartupLocation="CenterScreen" ShowMinButton="False" ShowMaxRestoreButton="False" ShowCloseButton="False" ResizeMode="NoResize" >

    <Window.Resources>
        <ResourceDictionary>
            <ControlTemplate x:Key="validationTemplate">
                <Grid>
                    <Border BorderThickness="2" BorderBrush="Red">
                        <AdornedElementPlaceholder x:Name="Holder"/>
                    </Border>
                    <Label Foreground="Red" HorizontalAlignment="Right" VerticalAlignment="Center" Content="{Binding ElementName=Holder, Path=AdornedElement.(Validation.Errors)[0].ErrorContent}"/>
                </Grid>
            </ControlTemplate>
        </ResourceDictionary>
    </Window.Resources>

    <Window.DataContext>
        <vm:AutoDetectViewModel/>
    </Window.DataContext>

    <DockPanel LastChildFill="True">
        <StackPanel  x:Name="staPrgBar" Visibility="Hidden" DockPanel.Dock="Bottom">
            <Controls:ProgressIndicator x:Name="prgSearch" ProgressColour="White"
                                    Margin="10" Height="6"/>

        </StackPanel>
        <DockPanel LastChildFill="True">
            <StackPanel DockPanel.Dock="Top">
                <Button x:Name="cmdSearch"
                Content="Search"
                Margin="10"
                Style="{DynamicResource SquareButtonStyle}"
                Command="{Binding Path=SearchCommand}"/>
            </StackPanel>
            <StackPanel Orientation="Horizontal" DockPanel.Dock="Bottom">
                <Button Style="{DynamicResource MetroCircleButtonStyle}"
                            		Height="55"
                            		Width="55"
                            		VerticalAlignment="Top"
                                    Command="{Binding Path=CloseCommand}">
                    <Rectangle Width="20" Height="20">
                        <Rectangle.Fill>
                            <VisualBrush Stretch="Fill" Visual="{StaticResource appbar_close}" />
                        </Rectangle.Fill>
                    </Rectangle>
                </Button>
                <Button Style="{DynamicResource MetroCircleButtonStyle}"
                            		Height="55"
                            		Width="55"
                            		VerticalAlignment="Top"
                                    Command="{Binding Path=SelectDeviceCommand}">
                    <Rectangle Width="20" Height="20">
                        <Rectangle.Fill>
                            <VisualBrush Stretch="Fill" Visual="{StaticResource appbar_navigate_next}" />
                        </Rectangle.Fill>
                    </Rectangle>
                </Button>
            </StackPanel>
            <StackPanel>
                <TextBlock Visibility="{Binding Path=ShowDeviceList, Converter={StaticResource boolToVis}}" Margin="10" Foreground="{StaticResource Foreground}" FontSize="16">Devicelist</TextBlock>
                <ListBox Visibility="{Binding Path=ShowDeviceList, Converter={StaticResource boolToVis}}" Margin="10" ItemsSource="{Binding DeviceList}" SelectedItem="{Binding SelectedDevice}" />

                <TextBlock Visibility="{Binding Path=ShowIpConfig, Converter={StaticResource boolToVis}}" Margin="10" Foreground="{StaticResource Foreground}" FontSize="16">No Device found check port</TextBlock>
                <Grid Visibility="{Binding Path=ShowIpConfig, Converter={StaticResource boolToVis}}" Margin="10">
                    <Grid.RowDefinitions>
                        <RowDefinition Height="Auto" />
                    </Grid.RowDefinitions>
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="Auto" />
                        <ColumnDefinition Width="*" />
                    </Grid.ColumnDefinitions>
                    <Label Grid.Row="0" Grid.Column="0" Content="IP-Port:"/>
                    <TextBox Grid.Row="0" Grid.Column="1" Margin="3" Validation.ErrorTemplate="{StaticResource validationTemplate}">
                        <Binding Path="IPPort" Mode="TwoWay" UpdateSourceTrigger="PropertyChanged" ValidatesOnDataErrors="True"/>
                    </TextBox>
                </Grid>
            </StackPanel>
        </DockPanel>
    </DockPanel>
</Controls:MetroWindow>
